home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / isdata.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.2 KB  |  103 lines

  1. /* Copyright (C) 1992, 1995, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: isdata.h,v 1.2 2000/09/19 19:00:46 lpd Exp $ */
  20. /* Structure for expandable stacks of refs */
  21. /* Requires iref.h */
  22.  
  23. #ifndef isdata_INCLUDED
  24. #  define isdata_INCLUDED
  25.  
  26. /*
  27.  * In order to detect under- and overflow with minimum overhead, we put
  28.  * guard elements at the top and bottom of each stack block (see idsdata.h,
  29.  * iesdata.h, and iosdata.h for details of the individual stacks).  Note that
  30.  * the 'current' and 'next' arrays include the guard elements.  See
  31.  * istack.h for the details of stack blocks.
  32.  */
  33.  
  34. /*
  35.  * The garbage collector requires that the entire contents of every block
  36.  * be 'clean', i.e., contain legitimate refs; we also need to ensure that
  37.  * at GC time, pointers in unused areas of a block will not be followed
  38.  * (since they may be dangling).  We ensure this as follows:
  39.  *      - When allocating a new block, we set the entire body to nulls.
  40.  *      This is necessary because the block may be freed before the next GC,
  41.  *      and the GC must be able to scan (parse) refs even if they are free.
  42.  *      - When adding a new block to the top of the stack, we set to nulls
  43.  *      the unused area of the new next-to-top blocks.
  44.  *      - At the beginning of garbage collection, we set to nulls the unused
  45.  *      elements of the top block.
  46.  */
  47.  
  48. /*
  49.  * Define pointers into stacks.  Formerly, these were short (unsegmented)
  50.  * pointers, but this distinction is no longer needed.
  51.  */
  52. typedef ref *s_ptr;
  53. typedef const ref *const_s_ptr;
  54.  
  55. /* Define an opaque allocator type. */
  56. #ifndef gs_ref_memory_DEFINED
  57. #  define gs_ref_memory_DEFINED
  58. typedef struct gs_ref_memory_s gs_ref_memory_t;
  59. #endif
  60.  
  61. /*
  62.  * Define the state of a stack, other than the data it holds.
  63.  * Note that the total size of a stack cannot exceed max_uint,
  64.  * because it has to be possible to copy a stack to a PostScript array.
  65.  */
  66. #ifndef ref_stack_DEFINED
  67. typedef struct ref_stack_s ref_stack_t;    /* also defined in idebug.h */
  68. #  define ref_stack_DEFINED
  69. #endif
  70. /*
  71.  * We divide the stack structure into two parts: ref_stack_params_t, which
  72.  * is set when the stack is created and (almost) never changed after that,
  73.  * and ref_stack_t, which changes dynamically.
  74.  */
  75. typedef struct ref_stack_params_s ref_stack_params_t;
  76. struct ref_stack_s {
  77.     /* Following are updated dynamically. */
  78.     s_ptr p;            /* current top element */
  79.     /* Following are updated when adding or deleting blocks. */
  80.     s_ptr bot;            /* bottommost valid element */
  81.     s_ptr top;            /* topmost valid element = */
  82.                 /* bot + data_size */
  83.     ref current;        /* t_array for current top block */
  84.     uint extension_size;    /* total sizes of extn. blocks */
  85.     uint extension_used;    /* total used sizes of extn. blocks */
  86.     /* Following are updated rarely. */
  87.     ref max_stack;        /* t_integer, Max...Stack user param */
  88.     uint requested;        /* amount of last failing */
  89.                 /* push or pop request */
  90.     uint margin;        /* # of slots to leave between limit */
  91.                 /* and top */
  92.     uint body_size;        /* data_size - margin */
  93.     /* Following are set only at initialization. */
  94.     ref_stack_params_t *params;
  95.     gs_ref_memory_t *memory;    /* allocator for params and blocks */
  96. };
  97. #define public_st_ref_stack()    /* in istack.c */\
  98.   gs_public_st_complex_only(st_ref_stack, ref_stack_t, "ref_stack_t",\
  99.     ref_stack_clear_marks, ref_stack_enum_ptrs, ref_stack_reloc_ptrs, 0)
  100. #define st_ref_stack_num_ptrs 2    /* current, params */
  101.  
  102. #endif /* isdata_INCLUDED */
  103.